<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

//当用get方式访问myblog.com/test 这个地址的时候用匿名函数去响应
Route::get('test',function(){
	return '123';
});
//当用post方式访问myblog.com/test 这个地址时用匿名函数去响应
Route::post('text',function(){
	return 'post';
});
//当get访问网站根目录'/'时,用第二个参数的匿名函数去响应
Route::get('/',function(){
	return 'hello';
});
//不管是get还是 post方法,访问myblog/user时,都用UserController中的method()方法去回应
Route::match(['get','post'],'user','UserController@method');
//get,post,put,delete.. 任何方法访问myblog.com/test,都用第二个参数中的匿名函数去响应
Route::any('test',function(){
	return 'Hello World';
});
//myblog.com/user/123 这样的url,user后面值将会捕捉到,并自动传递给控制器的方法或匿名函数
Route:: get('user/{id}',function($id){
	return 'User'.$id;
});
//myblog.com/user/{name}/{id} 这样的URL,user后的参数,会被捕捉到,并自动传递给控制器的方法或匿名函数
Route::get('user/{name}/{id}',function($name,$id){
	return 'User_'.$name.'-'.$id;
});
// 可选参数 在路由参数的花括号最后加上? 即可
/*Route::get('use/{name?}',function($name=''){
	// return $name;
	return 'A';
});*/
// Route::get('use/{name?}',function($name='john'){
// 	// return $name;
// 	return 'B';
// });

//参数限制
/*Route::get('use/{name}',function($name){
	return $name;
	// return 123;
})->where('name','[A-Za-z]+');*/

/*Route::get('use/{id}',function($id){
	return $id;
})->where('id','[0-9]+');*/
/*Route::get('use/{id}/{name}',function($id,$name){
	return $id.'-----'.$name;
})->where(['id'=>'[0-9]+','name'=>'[A-Za-z]+']);

Route::get('test','TestController@add');
Route::get('index','Admin\IndexController@index');
Route::get('up','Admin\IndexController@up');
Route::get('updata','UserController@updat');*/
/*Route::get('add','TestController@add');
Route::get('up','TestController@up');
Route::get('del','TestController@del');*/
Route::get('test','TestController@test');
Route::get('update','UserController@updat');
// Route::get('show','TestController@show');
//get/msg/index 展示留言列表
Route::get('msg/index','MsgController@index');
//get/msg/add 展示表单
// Route::get('msg/add','MsgController@add');
//post/msg/add 接受POST数据,并入库
// Route::post('msg/add','MsgController@addPost');
// [get,post] //添加留言
Route::match(['get','post'],'msg/add','MsgController@add');
//get/msg/del/{id} 删除留言
Route::get('msg/del/{id}','MsgController@del');
//[get,post] /msg/up{id} 修改留言
Route::match(['get','post'],'msg/up/{id}','MsgController@up');